<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Module: Sass::Callbacks</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (C)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span>
     &raquo; 
    <span class="title">Callbacks</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Module: Sass::Callbacks 
  
  
</h1>

<dl class="box">
  
  
    
  
    
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">/var/www/sass-pages/.sass/lib/sass/callbacks.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>A lightweight infrastructure for defining and running callbacks. Callbacks are defined using <tt><a href="#define_callback-instance_method" title="Sass::Callbacks#define_callback (method)">#define_callback</a></tt> at the class level, and called using <code>run_#{name}</code> at the instance level.</p>

<p>Clients can add callbacks by calling the generated <code>on_#{name}</code> method, and passing in a block that&#8217;s run when the callback is activated.</p>

  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <h3>Examples:</h3>
    
      <h4>Define a callback</h4>
      <pre class="example code">  class Munger
    extend Sass::Callbacks
    define_callback :string_munged

    def munge(str)
      res = str.gsub(/[a-z]/, '\1\1')
      run_string_munged str, res
      res
    end
  end</pre>
    
      <h4>Use a callback</h4>
      <pre class="example code">  m = Munger.new
  m.on_string_munged {|str, res| puts "#{str} was munged into #{res}!"}
  m.munge "bar" #=> bar was munged into bbaarr!</pre>
    
  </div>

</div><h2>Defined Under Namespace</h2>
<p class="children">
   
    
      <strong class="modules">Modules:</strong> <a href="InstanceMethods.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a>
    
   
    
  
</p>



  <h2>Class Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#extended-class_method" title="extended (class method)">+ <strong>extended</strong>(base) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Automatically includes <tt><a href="InstanceMethods.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a></tt> when something extends this module.</span>
  
</li>

    
  </ul>

  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="protected ">
  <span class="summary_signature">
    
      <a href="#define_callback-instance_method" title="#define_callback (instance method)">- <strong>define_callback</strong>(name) </a>
    

    
  </span>
  
  
  <span class="note title protected">protected</span>
  
  

  
    <span class="summary_desc">Define a callback with the given name.</span>
  
</li>

    
  </ul>


  <div id="class_method_details" class="method_details_list">
    <h2>Class Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="extended-class_method">
  
    + <strong>extended</strong>(base) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Automatically includes <tt><a href="InstanceMethods.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Callbacks/InstanceMethods.html" title="Sass::Callbacks::InstanceMethods (module)">InstanceMethods</a></tt> when something extends this module.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Module</tt>)</span>
      
      
        <span class='name'>base</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


30
31
32</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/callbacks.rb', line 30</span>

def self.extended(base)
  base.send(:include, InstanceMethods)
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="define_callback-instance_method">
  
    - <strong>define_callback</strong>(name)  <span class="extras">(protected)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p class="note returns_void">This method returns an undefined value.</p><p>Define a callback with the given name. This will define an <code>on_#{name}</code> method that registers a block, and a <code>run_#{name}</code> method that runs that block (optionall with some arguments).</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>Symbol</tt>)</span>
      
      
        <span class='name'>name</span>
      
      
      
        &mdash;
        The name of the callback
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


50
51
52</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/callbacks.rb', line 50</span>

def define_callback(name)
  class_eval "def on_\#{name}(&block)\n  @_sass_callbacks ||= {}\n  (@_sass_callbacks[\#{name.inspect}] ||= []) << block\nend\n\ndef run_\#{name}(*args)\n  return unless @_sass_callbacks\n  return unless @_sass_callbacks[\#{name.inspect}]\n  @_sass_callbacks[\#{name.inspect}].each {|c| c[*args]}\nend\nprivate :run_\#{name}\n", __FILE__, __LINE__ + 1
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:59 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>